package com.ht.pms.core.controller.user;

import com.ht.pms.core.controller.template.SalaryTemplateController;
import com.ht.pms.core.dto.Result;
import com.ht.pms.core.service.SalaryUserService;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SalaryUserController {
    private static final Logger LOG = LoggerFactory.getLogger(SalaryTemplateController.class);

    @Autowired
    private SalaryUserService salaryUserService;

    @GetMapping(value = "/updateUserInfo")
    @ResponseBody
    @ApiOperation("获取用户详情")
    public Result updateUserInfo(String startTime,String endTime) throws Exception {
        LOG.info("=================>>>>获取用户详情接口开始");
        Result result = null;
        try {
            salaryUserService.updateUserInfo(startTime,endTime);

            result = Result.buildSuccess();
        } catch (Exception e) {
            LOG.error("=============>>>>获取用户详情出错", e);
            result = Result.buildFail();
        }
        LOG.info("=================>>>>获取用户详情结束{}", result);
        return result;
    }

    @GetMapping(value = "/updateOrgInfo")
    @ResponseBody
    @ApiOperation("获取用户详情")
    public Result updateOrgInfo(String startTime,String endTime) throws Exception {
        LOG.info("=================>>>>更新用户组织接口开始");
        Result result = null;
        try {
            salaryUserService.updateOrgInfo(startTime,endTime);

            result = Result.buildSuccess();
        } catch (Exception e) {
            LOG.error("=============>>>>更新用户组织出错", e);
            result = Result.buildFail();
        }
        LOG.info("=================>>>>更新用户组织结束{}", result);
        return result;
    }

    @GetMapping(value = "/updateDdUser")
    @ResponseBody
    @ApiOperation("获取钉钉详情")
    public Result updateDdUser(String startTime,String endTime) throws Exception {
        LOG.info("=================>>>>更新钉钉数据接口开始");
        Result result = null;
        try {
            salaryUserService.updateDdUser(startTime,endTime);

            result = Result.buildSuccess();
        } catch (Exception e) {
            LOG.error("=============>>>>更新钉钉数据出错", e);
            result = Result.buildFail();
        }
        LOG.info("=================>>>>更新钉钉数据结束{}", result);
        return result;
    }

}
